#-*- coding: utf-8 -*-

def crop_video(video, rate=1.2):
    #video.size
    #finalClip = hzwVideoClip.crop(x1=200, y1=100, x2=600, y2=600)
    # 放大120%进行裁剪，再将视频设置尺寸为原来的尺寸
    origin_size = video.size
    x1 = int((rate - 1) * origin_size[0] / 2)
    y1 = int((rate - 1) * origin_size[1] / 2)
    x2 = int((1 - (rate - 1)) * origin_size[0]) + x1
    y2 = int((1 - (rate - 1)) * origin_size[1]) + y1

    # print(x1, y1, x2, y2)
    return video.crop(x1 = x1, y1 = y1, x2 = x2, y2 = y2).resize(origin_size)


if __name__ == "__main__":
    import moviepy.editor as mp
    crop_video(mp.VideoFileClip("./videos/test.mp4")).write_videofile("./videos/crop.mp4", codec="libx264", bitrate="10000000", audio_codec="aac")